<style type="text/css">
	div.head-con{
		border-bottom-width:0;
	}
	div.welcome{
		background-color:#F8F8F8;
		padding:1rem 0 0;
		text-align:center;
	}
	i.router{
		display:inline-block;
		background:url(/luci-static/images/password.png?_=20170809165512) no-repeat;
		background-size:contain;
		width:5rem;
		height:4rem;
	}
	div.btn-con-2{
		margin:1rem auto 0;
	}
</style>
<script type="text/javascript">
(function(){
	$("#Save").click(function(){
		var pwd = $("#PwdNew").val();
		var confirmPwd = $("#PwdCfm").val();

		if ("" == pwd){
			showNote(errStr.newpwdBlank);
			return;
		}

		if (false == checkIllegalChar(pwd)){
			showNote(errStr.newpwdHasInvChr);
			return;
		}

		if (getCNStrLen(pwd) < 5 || getCNStrLen(pwd) > 63){
			showNote(errStr.newpwdLengthErr);
			return;
		}

		if (pwd != confirmPwd){
			showNote(errStr.pwdNotSame);
			return;
		}

		var pwdEncoded = new Base64().base64encode(pwd);
		var data = {};

		data.username = "admin";
		data.password = pwdEncoded;

		apiRegister(data, function(result){
			var code = result[ERR_CODE];
			switch(code){
			case E_NONE:
				stateman.go("guideNetworkSet");
				break;
			case E_HASINITPWD:
				showAlert(errStr.pwdHasInit, function(){
					stateman.go("guideNetworkSet");
				});
				break;
			case E_PWDBLANK:
				showNote(errStr.newpwdBlank);
				break;
			case E_PWDLEN:
				showNote(errStr.newpwdLengthErr);
				break;
			case E_PWDILLEGAL:
				showNote(errStr.newpwdHasInvChr);
				break;
			default:
				showNote(errStr.unknownErr + code);
				break;
			}
		});
	});
})();
</script>
<div class="head-con">
	<h1 class="head-title">{%label.adminPwdSet%}</h1>
</div>
<div class="set-con below-head">
	<div class="welcome">
		<i class="router"></i>
	</div>
	<p class="set-con-desc">{%label.setAdminPwd%}</p>
	<ul class="set-con">
		<label class="desc-lbl">{%label.adminPwd%}</label>
		<li class="text-con">
			<input class="text ime-mode-n hover" maxLength="63" id="PwdNew" value="" placeholder="{%label.pwdLenTip%}" />
			<i class="tip icon-eye" data-value="0"></i>
		</li>
	</ul>
	<ul class="set-con">
		<label class="desc-lbl">{%label.confirmPwd%}</label>
		<li class="text-con">
			<input class="text ime-mode-n hover" maxLength="63" id="PwdCfm" value="" placeholder="{%label.pwdLenTip%}" />
			<i class="tip icon-eye" data-value="0"></i>
		</li>
	</ul>
	<div class="err-note hidden">
		<i class="err-icon icon_remind_line"></i>
		<p class="note-str"></p>
	</div>
	<div class="btn-con btn-con-2">
		<input id="Save" class="btn" type="button" value="{%btn.nextStep%}" />
	</div>
</div>